def sorting1(my_list):
    n = len(my_list) - 1
    i_limit = 1 - 1
    j_limit = 2 - 1
    if n < 2:
        return my_list
    for i in range(n, i_limit, -1):
        for j in range(n, j_limit, -1):
            k = j - 1
            if my_list[j] < my_list[k]:
                my_list[j], my_list[k] = my_list[k], my_list[j]
    return my_list


def sorting2(my_list):
    n = len(my_list) - 1
    i_limit = 2 - 1
    # j_limit = 2 - 1
    if n < 2:
        return my_list
    for i in range(n, i_limit, -1):
        j_limit = i - 1
        for j in range(n, j_limit, -1):
            k = j - 1
            if my_list[j] < my_list[k]:
                my_list[j], my_list[k] = my_list[k], my_list[j]
    return my_list


# TODO: Move to another module. Both of these have a bug, but they're close.
def sum1a(my_list):
    n = len(my_list)
    s = 0
    i = 1
    while True:
        if i <= n:
            j = 1
            while True:
                if j <= n:
                    j_index = j - 1
                    s = s + my_list[j_index]
                    j = j + 1
                else:
                    break  # pragma: no cover

            i = 2 * i
        else:
            break  # pragma: no cover
    return s


def sum1b(my_list):
    n = len(my_list)
    s = 0
    i = 1
    while True:
        if i <= n:
            j = 1
            while True:
                if j <= n:
                    j_index = j - 1
                    s = s + my_list[j_index]
                    j = j + i
                else:
                    break  # pragma: no cover

            i = 2 * i
        else:
            break  # pragma: no cover
    return s
